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;
- global real gOpenTime = 3.0;
- global real gOpeningTime = 1.2;
- global int gOpenSound = -1;
- global int gCloseSound = -1;
- global int gMsgSnd = 33;
- global int gVoiceOver = -1;
- global int gNeedAction = 0;
- global int gLockable = 0;
- global int gLocked = 0;
- global int gAuto = 1;
-
- Reset("dummy");
- }
-
- int opensound(string str)
- {
- gOpenSound = GetSoundIndex(str);
- }
-
- int closesound(string str)
- {
- gCloseSound = GetSoundIndex(str);
- }
-
- int msgsnd(string str)
- {
- gMsgSnd = GetSoundIndex(str);
- }
-
- int autodoor(string str)
- {
- gAuto = Str2Int(str);
- }
-
- int needaction(string dummy)
- {
- gNeedAction = 1;
-
- }
-
- int say(string soundname)
- {
- gVoiceOver = GetBrainVOSoundIndex(soundname);
- }
-
- int lockdoor(string str)
- {
- gLockable = Str2Int(str);
- gLocked = gLockable;
- }
-
- int Reset(string dummy)
- {
- CloseLowLevel();
- mystate = 2;
- SetCollidableProperties(thisObject,1,0);
-
- SetStyle(thisObject,1);
- if (gLockable == 1)
- gLocked = 1;
-
- }
-
-
- int start(string dummy)
- {
- TimedEvent(1);
-
- gLocked = 0;
- }
-
- int opentime(string time)
- {
- gOpenTime = Str2Real(time);
- }
-
- int openingtime(string time)
- {
- gOpeningTime = Str2Real(time);
- }
-
- int TimedEvent(int input)
- {
- real time;
- real phase;
- time = GetTime(thisObject);
-
- switch (mystate)
- {
- case 2:
- if (input == 1)
- {
- mystate = 3;
- wakeupTime = time + gOpeningTime;
- OpenLowLevel();
- }
- break;
- case 3:
- if ( input != 1)
- {
- phase = AnimGetPhase(thisObject);
- if (phase == 1.0)
- {
- if (gOpenTime == -1.0)
- mystate = 6;
- else
- mystate = 1;
- wakeupTime = time + gOpenTime;
- }
- else
- {
- wakeupTime = time + .1;
- AnimSetPhase(thisObject,1.0);
- }
- }
- break;
- case 1:
- {
- if (input == 1)
- {
- wakeupTime = time + gOpenTime;
- }
- else
- {
- wakeupTime = time + gOpeningTime;
- mystate = 4;
- CloseLowLevel();
- }
- }
- break;
- case 4:
- phase = AnimGetPhase(thisObject);
- if (phase == 0.0)
- {
- mystate = 2;
- AnimSetPhase(thisObject,0.0);
- wakeupTime = -1.0;
- }
- else
- {
- wakeupTime = time + 0.1;
- }
- break;
- case 6:
- wakeupTime = -1.0;
- break;
- default:
- break;
- }
- }
-
- int OpenLowLevel ()
- {
- Animate(thisObject,1,"open");
- AnimSetPhase(thisObject,0.0);
- AnimSetDirection(thisObject,0);
- PlaySound(thisObject,gOpenSound);
- return 0;
- }
-
- int CloseLowLevel ()
- {
- Animate(thisObject,1,"open");
- AnimSetPhase(thisObject,1.0);
- AnimSetDirection(thisObject,1);
- PlaySound(thisObject,gCloseSound);
- return 0;
- }
-
- int Colliders(string dummy) {
-
- int result;
- int valid = 1;
- int op2;
- map::iterator ix;
- map::iterator iy;
- map objInList;
- result = 0;
-
- if (IsAuthoritative(thisObject) != 1)
- return result;
-
- if (gAuto == 0)
- {
- if (mystate != 1)
- {
- valid = 0;
- }
- }
-
- if (valid == 1)
- {
- if (gLocked == 1)
- {
- objInList = Collisions(thisObject,0,3,0);
-
- ix = begin(objInList);
- iy = end(objInList);
-
- if (ix != iy)
- {
- if (gNeedAction == 1)
- {
- for ( ix ; ix != iy; ++ix )
- {
- op2 = IsOperating(first(dereference(ix)));
- if (op2 == 1)
- gLocked = 0;
- }
- }
- else
- gLocked = 0;
- }
-
- if (gLocked == 1)
- valid = 0;
- }
- else
- {
- if (gNeedAction == 1)
- {
- valid = 0;
- objInList = Collisions(thisObject,0,1,0);
-
- ix = begin(objInList);
- iy = end(objInList);
-
- for ( ix ; ix != iy; ++ix )
- {
- op2 = IsOperating(first(dereference(ix)));
- if (op2 == 1)
- valid = 1;
- }
- }
- }
-
- if (valid == 1)
- {
- objInList = Collisions(thisObject,0,1,0);
-
- ix = begin(objInList);
- iy = end(objInList);
-
- if (ix != iy)
- {
-
- Multicast(thisObject,"start","dum");
- }
- } else {
- SendEnglishMessage(thisObject);
- PlayVoiceOver(gVoiceOver);
- PlaySound(thisObject,gMsgSnd);
- }
- }
- }
-
- int Action(string key)
- {
- if (IsAuthoritative(thisObject) != 1)
- return;
- start("hello");
- return 0;
- }
-